package com.study.youlai.system.converter;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.study.youlai.system.model.bo.NoticeBO;
import com.study.youlai.system.model.entity.SysNotice;
import com.study.youlai.system.model.form.NoticeForm;
import com.study.youlai.system.model.vo.NoticeDetailVO;
import com.study.youlai.system.model.vo.NoticePageVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * @ClassName: NoticeConverter
 * @Description: 通知公告对象转换器
 * @Author: li
 * @Date: 2025/1/13 10:51
 * @Version 1.0
 **/
@Mapper(componentModel = "spring")
public interface NoticeConverter {


    @Mappings({
            @Mapping(target = "targetUserIds", expression = "java(cn.hutool.core.util.StrUtil.split(entity.getTargetUserIds(),\",\"))")
    })
    NoticeForm toForm(SysNotice entity);

    @Mappings({
            @Mapping(target = "targetUserIds", expression = "java(cn.hutool.core.collection.CollUtil.join(formData.getTargetUserIds(),\",\"))")
    })
    SysNotice toEntity(NoticeForm formData);

    NoticePageVO toPageVo(NoticeBO bo);

    Page<NoticePageVO> toPageVo(Page<NoticeBO> noticePage);

    NoticeDetailVO toDetailVO(NoticeBO noticeBO);
}
